﻿<?php
	ini_set('display_errors', true);
	error_reporting(E_ALL);
	require 'database.php';
	
	if (isset($_GET['sok'])) {
		//echo "Adresse det søkes etter: " . $_GET['sok']."<br />";
		$database = new database();
		$adresser = array();
		$adresser = $database->hentIpAdresserSok($_GET['sok']);
		if ($adresser == false)
			echo "Fant ingen adresser med det valgte søket";
			
		else {
			$counter = 0;
			echo "<table border='1' id='infoTable' class='tablesorter'>
					<thead>
						 <tr>
						   <th>Vlan</th>
						   <th>Adresse</th>
						   <th>Beskrivelse</th>
						   <th>Subnett</th>
						   <th>Gateway</th>
						   <th>DNS oppføring</th>
						   <th>Plassering</th>
						   <th>Type</th>
						   <th>Diverse</th>
						 </tr>
					 </thead>
					 <tbody>";
			if (!isset($adresser))
				alertDebug("variabel har ikke blitt satt");
			else {
				while ($counter < count($adresser)) {
					echo "<tr><td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['vlan'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()' >" . $adresser[$counter]['adresse'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['beskrivelse'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['subnett'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['gateway'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['dns_oppføring'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['plassering'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['type'] . "</div></td>
					<td><div contenteditable='true' class='ipID_" . $adresser[$counter]['id'] . "' onmouseup='findFocusElement()' onkeyup='lagreTabell()'>" . $adresser[$counter]['diverse'] . "</div></td>
					</tr>";
					$counter++;
				}
				echo "</tbody></table>";
			}
		}
	}


?>